package cn.santi.service.impl;

import cn.santi.domain.SDate;
import cn.santi.domain.StaffSetting;
import cn.santi.domain.StaffTime;
import cn.santi.mapper.SDateMapper;
import cn.santi.mapper.STimeMapper;
import cn.santi.mapper.SettingMapper;
import cn.santi.service.SettingService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SettingServiceImpl implements SettingService {
    @Autowired
    private SettingMapper sm;
    @Autowired
    private SDateMapper sdm;
    @Autowired
    private STimeMapper stm;
    @Override
    public List<StaffSetting> adminGetHomenakingList() {
        LambdaQueryWrapper<StaffSetting> wrapper = new LambdaQueryWrapper<>();
        return sm.selectList(wrapper);
    }

    @Override
    public List<SDate> getDate(Integer id) {
        LambdaQueryWrapper<SDate> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SDate::getSid,id);
        return sdm.selectList(wrapper);
    }

    @Override
    public List<StaffTime> getTime(Integer id) {
        LambdaQueryWrapper<StaffTime> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(StaffTime::getDid,id);
        return stm.selectList(wrapper);
    }

    @Override
    public StaffSetting getSettingById(int id) {
        LambdaQueryWrapper<StaffSetting> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(StaffSetting::getId,id);
        return sm.selectOne(wrapper);
    }
    @Override
    public int UpDataSetting(StaffSetting setting) {
        LambdaQueryWrapper<StaffSetting> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(StaffSetting::getId,setting.getId());
        return sm.update(setting,wrapper);
    }

    @Override
    public int DeleteSetting(int id) {
        return sm.deleteById(id);
    }

    @Override
    public List<StaffSetting> adminSearchHomenaking(String content) {
        return sm.adminSearchHomenaking(content);
    }

    @Override
    public List<StaffSetting> adminGethomemakingClassify(int i) {
        LambdaQueryWrapper<StaffSetting> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(StaffSetting::getState,i);
        return sm.selectList(wrapper);
    }
}
